<?php

class Application_Model_BoxUnit
{
	protected $_id;
	protected $_box_id;
	protected $_unit_num;
	protected $_unit_status;
	protected $_size_id;
	
	const STATUS_AVALIABLE = 'avaliable';
	const STATUS_OCCUPIED = 'occupied';
	
	public function __construct(array $options = null)
	{
		if (is_array($options)) {
			$this->setOptions($options);
		}
	}
	
	public function __set($name, $value)
	{
		$method = 'set' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid user property');
		}
		$this->$method($value);
	}
	
	public function __get($name)
	{
		$method = 'get' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid user property');
		}
		return $this->$method();
	}
	
	public function setOptions(array $options)
	{
		$methods = get_class_methods($this);
		foreach ($options as $key => $value) {
			$method = 'set' . ucfirst($key);
			if (in_array($method, $methods)) {
				$this->$method($value);
			}
		}
		return $this;
	}
	
	public function setId($id){
		$this->_id = $id;
		return $this;
	}
	
	public function getId(){
		return $this->_id;
	}
	
	public function setBoxId($bid){
		$this->_box_id = $bid;
		return $this;
	}
	
	public function getBoxId(){
		return $this->_box_id;
	}
	
	public function setUnitNum($num){
		$this->_unit_num = $num;
		return $this;
	}
	
	public function getUnitNum(){
		return $this->_unit_num;
	}
	
	public function setUnitStatus($status){
		$this->_unit_status = $status;
		return $this;
	}
	
	public function getUnitStatus(){
		return $this->_unit_status;
	}
	
	public function setSizeId($sid){
		$this->_size_id = $sid;
		return $this;
	}
	
	public function getSizeId(){
		return $this->_size_id;
	}
	
	


}

